package com.aj.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.aj.activity.view.GestureContentView;
import com.aj.activity.view.GestureDrawl.GestureCallBack;
import com.aj.sharepreferences.LoveHomeSharedPreferences;

public class HomesRelationGesturePasswordActivity extends BaseActivity {

	private FrameLayout body_layout;
	private TextView alertmessage_text;
	private GestureContentView content;
	private Context mContext;

	public static void newInstance(Context context) {
		Intent intent = new Intent(context,
				HomesRelationGesturePasswordActivity.class);
		context.startActivity(intent);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_gesture);
		mContext = this;
		initView();
	}

	private void initView() {
		setActionBarTitle(R.string.safe_update_gesture_password_unlock_text);
		body_layout = (FrameLayout) findViewById(R.id.body_layout);
		alertmessage_text = (TextView) findViewById(R.id.alertmessage_text);
		alertmessage_text.setText(getString(R.string.gesture_password_text));
		String gesturePassword = LoveHomeSharedPreferences.getGesturePassowrd()
				.trim();
		content = new GestureContentView(this, gesturePassword,
				new GestureCallBack() {
					@Override
					public void checkedSuccess() {
						HomesRelationActivity.newInstance(mContext);
						finish();
					}

					@Override
					public void checkedFail() {
						Toast.makeText(
								mContext,
								getString(R.string.safe_update_gesture_password_error_text),
								Toast.LENGTH_LONG).show();
					}
				});
		content.setParentView(body_layout);
	}
}
